Resolve export * as ns re-exports under modern parsers#3250
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3250 +/- ##
==========================================
- Coverage 95.68% 95.52% -0.16%
==========================================
Files 83 83
Lines 3705 3709 +4
Branches 1342 1342
==========================================
- Hits 3545 3543 -2
- Misses 160 166 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2 tasks
15dcddd to
b4e961f
Compare
ljharb
approved these changes
May 20, 2026
8e5c66b to
d4de15e
Compare
Themoor1
approved these changes
May 21, 2026
ljharb
pushed a commit
that referenced
this pull request
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two pre-existing
ExportAllDeclarationbugs that affect modern parsers (espree ES2020+,@babel/eslint-parser) but notbabel-eslint. Extracted from #3230 (eslint v10 support) to make that PR cleaner.Root cause
babel-eslintrepresentsexport * as ns from './mod'asExportNamedDeclaration+ExportNamespaceSpecifier(a working code path), so the bug was latent. Modern parsers emitExportAllDeclarationwithexported, which hit two broken spots:specifier.js: passed a string (specifier.source.value) tonamespace.add(), which expects an AST node — so the namespace getter was never set up andnsdidn't resolve. Fixed by defining the lazy getter directly, matching the existingExportNamespaceSpecifiercase.visitor.js:export * as nswas unconditionally added to the star-exportdependenciesset, incorrectly flattening the target module's exports into the current one. Fixed by only adding todependenciesfor plainexport *(noas).Tests
The included regression test covers the false negative: the
namespacerule now correctly flags invalid deep references throughexport * asre-exports that were previously silently missed (fails onmain, passes with the fix).The false-positive symptoms #1834, #1883, #1845, #2002, #2289 ("errors after upgrading Babel") are resolved by the same change, but only reproduce with
@babel/eslint-parser, which is introduced in #3230.Fixes #2002, #1883, #1834, #1845, #2289.